home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / RGASM.RAR / ASMCODE.EXE / CHAPT10 / PRINDOS.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-05-10  |  2.3 KB  |  54 lines

  1. ;****************************************************************
  2. ;  Program PrinDos ( Chapter 10 )
  3. ;
  4. ;  The program for outputting text string otno the printer
  5. ;
  6. ;  Author: A.I.Sopin, Voronezh, Russia,  1991
  7. ;
  8. ;  The MS-DOS service (INT 21h, function 40h) is used
  9. ;
  10. ;****************************************************************
  11.  
  12. ;----------------------------------------------------------
  13. DATA     SEGMENT
  14. CR       EQU    13
  15. LF       EQU    10
  16. MSG1     DB     ' Output a string onto the printer (MS-DOS, INT 21h, AH=40h) '
  17.      DB     CR, LF
  18. LMSG1    EQU    $-MSG1
  19. MSG2     DB     13,10, 'Error while outputting the string !!!',13,10,'$'
  20. MSG3     DB     13,10, 'Printer not ready !!!',13,10,'$'
  21. MSG4     DB     13,10, 'Error during printer initialisation !!!',13,10,'$'
  22. DATA     ENDS
  23. ;----------------------------------------------------------
  24.  
  25. CODE     SEGMENT 'CODE'
  26.      ASSUME CS:CODE, DS:DATA
  27. ;--- Check whether printer is ready
  28. Begin:   mov    ax,DATA         ;
  29.      mov    DS,ax           ;  DS points to data segment
  30.      mov    ah,2            ;  function 03h - get printer status byte
  31.      xor    dx,dx           ;  DX=0 corresponds to LPT1
  32.      int    17h             ;  BIOS printer service 
  33.      cmp    ah,90h          ;  check bits 7 and 4 of status byte
  34.      je     Print           ;  if printer is OK - print
  35.      lea    dx,MSG3         ;  address of message "not ready"
  36.      jmp    Text            ;  output message and exit
  37. ;----------------------------------------------------------
  38. ;--- Output ASCII string onto the printer
  39. Print:   mov    cx,LMSG1        ;  length of string to be output
  40.      lea    dx,MSG1         ;  DS:DX - addres of beginning of string
  41.      mov    bx,4            ;  4 is value of file handle for LPT1
  42.      mov    ah,40h          ;  function 40h - write file with handle
  43.      int    21h             ;  DOS service call
  44.      jnc    Exit            ;  if Carry Flag is clear, exit
  45. Error:   lea    dx,MSG2         ;  else output error message
  46. ;----------------------------------------------------------
  47. ;--- This is the final block
  48. Text:    mov    ah,9            ;  function 09h - output text string
  49.      int    21h             ;  DOS service call
  50. Exit:    mov    ax,4C00h        ;  Function 4Ch - terminate process; Return Code  =0
  51.      int    21h             ;  Return to  MS-DOS
  52. CODE     ENDS
  53.      END    Begin
  54.